import * as actionType from '../../Info/store/constants';
import {
    reqinfo,
    reqcommonts
} from '../../../api/index'


export const changeGoodnumberData = (commonts) => {
    // console.log(commontsindex,index, number, '进去修改中 data')
    return (dispatch) => {
        // console.log(index, number, 'res 修改');
        dispatch(changeGoodnumberData2(commonts))
    }

}
export const changeGoodnumberData2 = (commonts) => {
    // console.log(commonts,commontsindex,index,number,'--------------------');
    return {
        type: actionType.CHANGE_GOODNUMBERDATA,
        data: commonts
    }
}

export const getInfoData = () => {
    console.log('进去了');
    return (dispatch) => {
        reqinfo()
            .then((res) => {
                // console.log(res,'999999');
                // console.log(res.data.data.navtitle,'123456');
                // console.log(res.data.data.category[0].result.branditems,'djlksajflkdsjalk');
                dispatch(changeInfoData(res.data.data.navtitle))
            })
            .catch((e) => {
                console.log('出错了');
            })
    }
}

export const changeInfoData = (data) => {
    // console.log(data,'0000000');
    return {
        type: actionType.CHANGE_INFO,
        data: data
    }
}

export const getCommontslist = () => {
    console.log('commonts 进去了');
    return (dispatch) => {
        reqcommonts()
            .then((res) => {
                // console.log(res.data.data.array, '999999');
                dispatch(changeCommontsData(res.data.data.array))
                // console.log('111');
            })
            .catch((e) => {
                // console.log('commonts出错了');
                console.log(e);
            })
    }
}

export const changeCommontsData = (data) => {
    // console.log(data, 'changeCommontsData');
    return {
        type: actionType.CHANGE_COMMONTSLIST,
        data: data
    }
}